package com.twu.biblioteca;

import com.twu.biblioteca.model.Account;
import com.twu.biblioteca.model.Book;
import com.twu.biblioteca.model.Movie;
import com.twu.biblioteca.model.Status;

import java.util.ArrayList;
import java.util.List;

import static com.twu.biblioteca.model.LoginStatus.login;

public class Library {
    private List<Book> books = new ArrayList<Book>();
    private ArrayList<Movie> movies = new ArrayList<Movie>();
    private List<Account> accounts = new ArrayList<Account>();


    public List<Book> getBooks() {
        return books;
    }


    public void initBooks(List<Book> books) {
        this.getBooks().addAll(books);
    }

    public Book findBook(int bookId) {
        for (Book book : books) {
            if (book.getBookId() == bookId) {
                return book;
            }
        }
        return null;
    }

    public void markBookStatus(Book book, Status status) {
        book.setStatus(status);
    }

    public void initMovies(List<Movie> movies) {
        this.getMovies().addAll(movies);
    }

    public void initAccounts(List<Account> accounts) {
        this.getAccounts().addAll(accounts);
    }

    public List<Account> getAccounts() {
        return accounts;
    }

    public List<Movie> getMovies() {
        return movies;
    }

    public Movie findMovie(int movieId) {
        for (Movie movie : movies) {
            if (movie.getMovieId() == movieId) {
                return movie;
            }
        }
        return null;
    }

    public void markMovieStatus(Movie movie, Status status) {
        movie.setStatus(status);
    }

    public void markUserLogin(Account account) {
        account.setStatus(login);

    }

    public Account findUser(String accountId) {
        for (Account account : accounts) {
            if (account.getAccountId().equals(accountId)) {
                return account;
            }
        }
        return null;
    }
}
